<?php

/**
 * @author Rizky Tahara Shita
 * @website http://tahara.web.id
 * @email rizky.tahara@gmail.com
 * @copyright b'IT Cyber Solution
 */

class M_template extends BZ_Model
{
/**
 * @section CSS
 */

	/**
	 * @function css_generate
	 * @description generate the css
	 */
	function css_generate($prm_css_files, $prm_themes_name, $prm_css_path = '')
	{
		if (is_array($prm_css_files))
		{
			if (trim($prm_css_path) == '')
			{
				$prm_css_path = $this->web_data['BISKITZ']['SETTINGS']['BISKITZ_THEME_ADMIN_CSS_PATH'];
			}


			foreach ($prm_css_files as $css_scripts)
			{
				foreach ($css_scripts as $css_files => $css_media)
				{
					if ( ! is_null($css_media))
					{
						$return_value[] = link_tag
							(
								base_url().'themes/'.$prm_themes_name.'/css/'.$prm_css_path.'/'.$css_files.'.css'
								, 'stylesheet'
								, 'text/css'
								, ''
								, $css_media
							);
					}
				}
			}


			return $return_value;
		}
	}




/**
 * @section Javascript
 */

	/**
	 * @function js_generate
	 * @description genereate the javascript
	 */
	function js_generate($prm_js_files, $prm_language = '')
	{
		if (is_array($prm_js_files))
		{
			if (trim($prm_language) == '')
			{
				if ($this->session->userdata('session_user_language_abbr'))
				{
					$prm_language = $this->session->userdata('session_user_language_abbr');
				}
				else
				{
					$prm_language = $this->web_data['BISKITZ']['SETTINGS']['BISKITZ_LANGUAGE'];
				}
			}

			$jquery_version = '1.7.2.min';

			/**
			 * @description load the javascript language
			 */
			$js_validate_language_use = FALSE;
			$js_language = array('en', 'id');

			$js_language = array_keys($js_language, $prm_language);
			$js_language = $js_language[0];

			$return_value[] = '<script>js_url_base="'.site_url().'"; js_language_active='.$js_language.';';
			if (isset($this->bz_segment['URL']))
				$return_value[] = 'js_url_current="'.site_url($this->bz_segment['URL']).'";';
			$return_value[] = '</script>';


			$return_value[] = '<script type="text/javascript" src="'.base_url().'js/plugins/jquery-'.$jquery_version.'.js"></script>';
			foreach ($prm_js_files as $js_file_path => $js_files)
			{
				if ( ! is_null($js_files))
				{
					foreach ($js_files as $js_file)
					{
						$return_value[] = '<script type="text/javascript" src="'.base_url().$js_file_path.'/'.$js_file.'.js"></script>';
						if ($js_file_path == 'js/plugins/validate' && $js_validate_language_use == FALSE && $js_language != 'en')
						{
							$return_value[] = '<script type="text/javascript" src="'.base_url().$js_file_path.'/localization/messages_'.$prm_language.'.js"></script>';
							$js_language_use = TRUE;
						}
					}
				}
			}


			return $return_value;
		}
	}



}

/** End of file m_template.php */
/** Location: ./biskitz_mpc/biskitz/models/m_template.php */